package com.peace.hospital.mapper.drugstorage;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.peace.hospital.entity.drugstorage.Damagedrug;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xie
 * @since 2019-11-23
 */
@Mapper
public interface DamagedrugMapper extends BaseMapper<Damagedrug> {

//    插入报损药品信息
    @Insert("insert into drugstorage.damagedrug(drugid,frmid,damnum,damdate,damreason)\n"+
            "values(#{drugid},#{frmid},#{damnum},#{damdate},#{damreason})")
    public int addDamageDrug(Damagedrug damagedrug);
// 查询报损药品

    @Select("select damid,drugid,damnum,damdate,damreason\n"+
            "from drugstorage.damagedrug where frmid=#{frmid}")
    @Results({
            @Result(column="drugid",property="druginformation",one=@One(select="com.peace.hospital.mapper.publicn.DruginformationMapper.selectById",fetchType= FetchType.LAZY)),
    })
    public List<Damagedrug> findDamageById(Damagedrug damagedrug);
}
